﻿#include<iostream>
using namespace std;
#define DELIVERY 1000000007
bool judgeConflict(int l, int r, int d) {
    if ((r - l) % d == 0) 
       return true;
    else 
       return  false;
    //加注释
      //几句
    //jjuju
   //xyh到此一游
   //xsb到此一游
    //xinjia
}

int oneSection(int l, int r) {
    int num = 0;
    int len = r - l;
    for (int i = 1; i <= len / 2; i++) {
        if (0 == len % i)
            num++;
    }
    return num;
}

int mulSection(int l, int r, int arr[]) {
    //int barLen =n;
    int num = 0;
    int len = r - l;
    int kl = 0;
    int kr = 0;
    
    for (; arr[kl] < l; kl++) {};
    for (kr = kl; arr[kr] < r; kr++) {};
    
    for (int i = 1; i <= len / 2; i++) {
        int flag = true;
        if (0 == len % i) {
           // cout << "kr=" << kr << "l=" << l << endl;
            int j;
            for (j = kl+1; j <= kr-1; j++) {                
                    if (judgeConflict(l, arr[j], i)) {
                        flag = false;
                        break;
                    }
               
            }
            //cout << "i=" << i;
            if (flag) {
               // cout << "i=" << i;
                num++;
            }
        }
    }
    return num;
}







int main() {
    int n;
    cin >> n;
    int a[5] ;
    int x;
    for ( x = 0; x < 5; x++) {
        a[x] = x;
    }
    int* m = new int[n];
    int *barrier=new int[n];
   /* int** sum = new int* [n];
    for (int i = 0; i < n; i++) {
        sum[i] = new int[n];
    }*/
   // cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> barrier[i];
    }
    /*for (int i = 0; i < n - 1;i++) {
        sum[i][i + 1] = oneSection(barrier[i], barrier[i + 1]);
    }*/
    m[0] = 1;//实际不是1,只是为了特定的计算
    m[1] = oneSection(barrier[0], barrier[1]);
    //cout << m[1 ]<< endl; 
    for (int i = 2; i < n; i++) {
        int tmp = 0;
        tmp = oneSection(barrier[i-1], barrier[i]);
        tmp = (m[i - 1] * tmp)%DELIVERY;
        for (int j = i - 2; j >= 0; j--) {
            int t= mulSection(barrier[j], barrier[i],barrier);
            //cout <<"t="<< t << endl;
            tmp += (t * m[j])%DELIVERY;
        }
        m[i] = tmp%DELIVERY;
    }
    cout << m[n - 1] << endl;
    delete [] barrier;
    delete [] m;
}